function Person(name, age, friends) {
  this.name = name;
  this.age = age;
  this.friends = friends;
}
Person.prototype.eating = function () {
  console.log(`${this.name}eating`);
};

function Student(name, age, sex, friends) {
  Person.call(this, name, age, friends);
  this.sex = sex;
}

Student.prototype = new Person();

Student.prototype.studying = function () {
  console.log(`${this.name}studying`);
};

let stu1 = new Student("张三", 18, "男", []);
let stu2 = new Student("李四", 20, "女", []);
stu1.friends.push("lisi");
console.log(stu1);
console.log(stu2);

//借用构造函数也是有弊端的，
//Person函数至少被调用了两次，
// stu的原型对象上会多出来一些属性， 但是这些属性没有存在的必要
